package com.wang.designpattern.composite;

import java.util.ArrayList;
import java.util.List;

/**
 * University就是Composite，可以管理College
 */
public class College extends OrgComponent {

    List<OrgComponent> orgComponentList = new ArrayList<>();

    public College(String name, String des) {
        super(name, des);
    }

    @Override
    protected void add(OrgComponent orgComponent) {
        orgComponentList.add(orgComponent);
    }

    @Override
    protected void remove(OrgComponent orgComponent) {
        orgComponentList.remove(orgComponent);
    }

    @Override
    public void print() {
        // 输出学院名称
        System.out.println("---------" + getName() + "---------");
        // 遍历orgComponentList
        for (OrgComponent orgComponent : orgComponentList) {
            orgComponent.print();
        }
    }
}
